package com.zhanghe.study.design_pattern.memento_pattern;

/**
 * 备忘录模式
 * @author zh
 * @date 2022/10/18 11:58
 */
public class Main {
    public static void main(String[] args) {
        Origintor origintor = new Origintor();
        origintor.setState("init");
        System.out.println("初始"+origintor.getState());

        Memento memento = origintor.createMemento();
        Caretaker caretaker = new Caretaker();
        caretaker.saveMemento(memento);

        origintor.setState("running");
        System.out.println("运行"+origintor.getState());
        origintor.setMemento(caretaker.retriveMemento());

        System.out.println("回滚"+origintor.getState());


    }
}
